package com.yohann.designPattern.observer.client;

import com.yohann.designPattern.observer.data.WeatherData;
import com.yohann.designPattern.observer.observer.BaiDuSite;
import com.yohann.designPattern.observer.observer.CurrentCondition;

/**
 * <p>
 * 客户端
 * </p>
 *
 * @author Yohann
 * @since 2021/2/12 17:14
 */
public class Client {
    public static void main(String[] args) {
        WeatherData data = new WeatherData();
        CurrentCondition condition = new CurrentCondition();
        data.registerObserver(condition);

        //CurrentCondition{temperature=10.0, pressure=100.0, humidity=30.0}
        data.setData(10f,100f,30f);

        BaiDuSite baiDuSite = new BaiDuSite();
        data.registerObserver(baiDuSite);

        /*
         * CurrentCondition{temperature=11.0, pressure=99.0, humidity=20.9}
         * BaiDuSite{temperature=11.0, pressure=99.0, humidity=20.9}
         */
        data.setData(11f,99f,20.9f);
    }
}